package com.atguigu.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.ApartmentFacility;
import com.atguigu.lease.web.admin.service.ApartmentFacilityService;
import com.atguigu.lease.web.admin.mapper.ApartmentFacilityMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
* @author liubo
* @description 针对表【apartment_facility(公寓&配套关联表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class ApartmentFacilityServiceImpl extends ServiceImpl<ApartmentFacilityMapper, ApartmentFacility>
    implements ApartmentFacilityService{
    @Override
    public void insertByIdsAndItemId(Long itemId, List<Long> ids) {
        if (!CollectionUtils.isEmpty(ids)) {
            List<ApartmentFacility> apartmentInfos = new ArrayList<>();
            for (Long id : ids) {
                ApartmentFacility facility = new ApartmentFacility();
                facility.setApartmentId(itemId);
                facility.setFacilityId(id);
                apartmentInfos.add(facility);
            }
            this.saveBatch(apartmentInfos);
        }
    }
}




